namespace Sharpmark.PerfectLife.Core.Picture
{
    using System;
    using System.Drawing;

    public class Photo
    {
        public Bitmap Bitmap { get; protected set; }

        public int Height
        {
            get { return Bitmap.Height; }
        }

        public int Width
        {
            get { return Bitmap.Width; }
        }

        private Photo()
        {
            Bitmap = new Bitmap(200, 200);
        }

        public Photo(Image original, int width, int height)
        {
            Bitmap = new Bitmap(original, width, height);
        }

        public Photo(Image original)
            : this(original, original.Width, original.Height)
        {
        }

        public Photo(Image original, Size newSize)
            : this(original, (newSize.Width != 0) ? newSize.Width : 0, (newSize.Height != 0) ? newSize.Height : 0)
        {
        }

        public Photo(int width, int height, System.Drawing.Imaging.PixelFormat format)
        {
            Bitmap = new Bitmap(width, height, format);
        }

        public Photo(int width, int height)
            : this(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
        {
        }

        public Photo(int width, int height, System.Drawing.Graphics g)
        {
            Bitmap = new Bitmap(width, height, g);
        }

        public Photo(string filename)
        {
            Bitmap = new Bitmap(filename);
        }

        public Photo GetThumbnailImage(int width, int height)
        {
            return new Photo(Bitmap.GetThumbnailImage(width, height, null, IntPtr.Zero));
        }

        public Color GetPixel(int x, int y)
        {
            return Bitmap.GetPixel(x, y);
        }
    }
}